<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>可用现金头寸表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 注意：项目正式环境请勿引用该地址 -->
    <link rel="stylesheet" href="layui/css/layui.css"/>
    <script type="text/javascript" src="layui/layui.js"></script>
    <script type="text/javascript" src="layui/tableSelect.js"></script>
</head>
<body>
<table class="layui-hide" id="test" lay-filter="test"></table>

<script type="text/html" id="toolbarDemo">
    <form class="layui-form layui-col-space5">
        <div class="layui-inline layui-show-xs-block">
            <label class="layui-form-label layui-bg-gray" style="width: 110px;text-align: center">日期</label>
            <div class="layui-inline layui-show-xs-block" style="width: 195px">
                <input class="layui-input" placeholder="请输入日期" name="dateTime" id="start">
            </div>
        </div>
        <div class="layui-inline layui-show-xs-block">
            <button class="layui-btn layui-btn-primary" lay-submit="" lay-event="search" lay-filter="sreach"><i class="layui-icon">&#xe615;</i>搜索
            </button>
        </div>
    </form>
</script>

<script>
    layui.use(['element', 'form', 'table', 'layer', 'laydate'], function () {
        var layer = layui.layer;
        var $ = layui.$;
        var table = layui.table;
        var form = layui.form;
        var laydate = layui.laydate;



        table.render({
            elem: '#test'
            , url: 'selectCashPositionStatement'
            , toolbar: '#toolbarDemo' //开启头部工具栏，并为其绑定左侧模板
            , defaultToolbar: ['filter', 'exports', 'print']
            ,height:'full-55'
            , minLength: 80
            , cellMinWidth: 500
            , cols:
                [
                    [
                        , {field: 'accountName', title: '科目名称',width:500, align: 'center'}
                        , {
                        field: 'money', title: '头寸金额', align: 'center' ,
                        templet: function(item) {
                            // alert("头寸金额"+item.money);
                            if (item.money<0) {
                                return "<span style='color: red'>"+(-Number(item.money))+"</span>";
                            }else{
                                return "<span '>"+item.money+"</span>";
                            }
                        }}

                    ]
                ]
            , page: true
        });
        //刷新表格
        table.reload('test');
        laydate.render({
            elem: '#start'
        });
        //给工具条的按钮添加事件
        table.on('toolbar(test)', function (obj) {
            switch (obj.event) {
                case "search":
                    var dateAccrualStock=$('#start').val();
                    table.reload('test', {
                        method: 'post',
                        page: {
                            curr: 1
                        },
                        where:{
                            'dateAccrualStock':dateAccrualStock
                        }
                    });
                    laydate.render({
                        elem:'#start'
                    });
                    break;
            }
        })
    })

</script>
</body>
</html>